<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>xhr查询参数</title>
</head>

<body>
  <script>
    const xhr = new XMLHttpRequest()
    xhr.open('get', 'http://hmajax.itheima.net/api/city?pname=辽宁省')
    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4 && xhr.status === 200) {
        console.log(xhr.response)// 字符串
        console.log(JSON.parse(xhr.response))// 对象
        console.log(JSON.parse(xhr.response).list.join('</br>'))// 字符串
        document.body.innerHTML = JSON.parse(xhr.response).list.join('</br>')
      }
    }
    xhr.send()
  </script>
</body>

</html>